#include<bits/stdc++.h>
using namespace std;

const int MAXN = 1010;
void dfs(vector<vector<char>>& grid, int r, int c) {
    int nr = grid.size();
    int nc = grid[0].size();
    grid[r][c] = '.';
    if (r - 1 >= 0 && grid[r - 1][c] == '#') dfs(grid, r - 1, c);
    if (r + 1 < nr && grid[r + 1][c] == '#') dfs(grid, r + 1, c);
    if (c - 1 >= 0 && grid[r][c - 1] == '#') dfs(grid, r, c - 1);
    if (c + 1 < nc && grid[r][c + 1] == '#') dfs(grid, r, c + 1);
}
int numIslands(vector<vector<char>>& grid) {
    int nr = grid.size();
    if (!nr) return 0;
    int nc = grid[0].size();

    int num_islands = 0;
    for (int r = 0; r < nr; ++r) {
        for (int c = 0; c < nc; ++c) {
            if (grid[r][c] == '#') {
                ++num_islands;
                dfs(grid, r, c);
            }
        }
    }
    return num_islands;
}

int main() {
    int n;
    string s;
    getline(cin, s);
    sscanf(s.c_str(), "%d", &n);
    vector<string> vec;
    while (n--) {
        string line;
        getline(cin, line);
        vec.push_back(line);
    }
    bool flag[MAXN][MAXN];
    memset(flag, false, sizeof(flag));
    int cnt = 0;
    for (int row = 0; row < vec.size(); row++) {
        for (int col = 0; col < vec[0].length(); col++) {
            if (vec[row][col] == '.') {
                if (row >= 1 && col >= 0) flag[row - 1][col] = true;
                if (row < vec.size() - 1 && col >= 0) flag[row + 1][col] = true;
                if (row >= 0 && col >= 1) flag[row][col - 1] = true;
                if (row >= 0 && col < vec[0].length() - 1) flag[row][col + 1] = true;
            }
        }
    }
    vector<vector<char>> land;
    for (int row = 0; row < vec.size(); row++) {
        vector<char> temp;
        for (int col = 0; col < vec[0].length(); col++) {
            if (vec[row][col] == '#' && !flag[row][col]) temp.push_back('#');
            else temp.push_back('.');
        }
        land.push_back(temp);
    }
    vector<vector<char>> pre;
    for (int row = 0; row < vec.size(); row++) {
        vector<char> temp;
        for (int col = 0; col < vec[0].length(); col++) {
            temp.push_back(vec[row][col]);
        }
        pre.push_back(temp);
    }
    cout << numIslands(pre) - numIslands(land) << endl;
    return 0;
}